package com.suse.service.community.util;

import com.suse.service.community.entity.User;

/**
 * <p>
 * 用户信息持有者
 * 线程本地变量
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-08-30 20:42
 */
public class UserHolder {

    private static final ThreadLocal<User> threadLocal = new ThreadLocal<>();

    public static void setUser(User user) {
        threadLocal.set(user);
    }

    public static User getUser() {
        return threadLocal.get();
    }

    public static void removeUser() {
        threadLocal.remove();
    }

}
